var rfid_code =  GetQueryString("rfidCode");
var bookBorrowStartTimeA = "";
if(GetQueryString("bookBorrowStartTimeA")!="null"){
	bookBorrowStartTimeA = GetQueryString("bookBorrowStartTimeA")
};
var bookBorrowStartTimeB = "";
if(GetQueryString("bookBorrowStartTimeB")!="null"){
	bookBorrowStartTimeB = GetQueryString("bookBorrowStartTimeB");
};
var bookBorrowEndTimeA = "";
if(GetQueryString("bookBorrowEndTimeA")!="null"){
	bookBorrowEndTimeA = GetQueryString("bookBorrowEndTimeA");
};
var bookBorrowEndTimeB = "";
if(GetQueryString("bookBorrowEndTimeB")!="null"){
	bookBorrowEndTimeB = GetQueryString("bookBorrowEndTimeB");
}
$(function () {
    $("#jqGrid").jqGrid({
    	url: baseURL + 'operation/book/getBookBorrowCount?rfidCode='+rfid_code+'&bookBorrowStartTimeA=' + bookBorrowStartTimeA +
		'&bookBorrowStartTimeB=' + bookBorrowStartTimeB +
		'&bookBorrowEndTimeA=' + bookBorrowEndTimeA +
		'&bookBorrowEndTimeB=' + bookBorrowEndTimeB,
        datatype: "json",
        colModel: [			
        	{ label: 'id', name: 'id', key: true,width:70 },
			{ label: '客户姓名', name: 'userName',index:"user_name",width:100,align:'center' },
			{ label: '手机号码', name: 'mobileNo',index:"mobile_no" ,width:120,align:'center' },
			{ label: '借阅开始时间', name: 'createTime', index:"create_time",width:170 ,align:'center'},
			{ label: '归还时间', name: 'modifyTime',index:"modify_time",width:170 ,align:'center' },
			{ label: '本次借阅时长(H)', name: 'timeCount',index:"time_count",width:120 ,align:'center' },
			{ label: '本次借阅费用(元)',name:'transAmount',index:"trans_amount",width:120,align:'center'},
			{ label: '用户类型',name:'userType',index:"trans_amount",width:80,align:'center',
				formatter:function(value,options,rowObject){
					if(value==1){
						return "运维人员";
					}else if(value==0){
						return "普通用户";
					}
				}
			},
			{ label: '借阅状态', name: 'status',index:"create_time",width:80 ,align:'center',
				formatter:function(value,options,rowObject){
					console.log(rowObject.userType);
					if(rowObject.userType==1){
						return "已下架";
					}else if(rowObject.modifyTime==null){
						return "借阅中";
					}else{
						return "已归还";
					}
				}
			},
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50,100,200],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        autoScroll:true,
        shrinkToFit:false,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        }
        
    });
    /*创建jqGrid的操作按钮容器*/
    /*可以控制界面上增删改查的按钮是否显示*/
    //jQuery("#jqGrid").jqGrid('navGrid', '#jqGridPager', {edit : true,add : true,del : true});
    //表格宽度自适应
    $(function(){
       $(window).resize(function(){
          $("#jqGrid").setGridWidth($(window).width());
       });
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			userName: null,
        },
		showList: true,
		title: null,
		marketBook: {}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam', {
				postData : {
					'userName' : vm.q.userName,
				},
				page : page
			}).trigger("reloadGrid");
		}
	}
});